<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>订单 </title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../../css/reset.css" />
		<link rel="stylesheet" href="../../../css/mui.min.css" />
		<link rel="stylesheet" href="../../../css/iconfont.css" />
		<link rel="stylesheet" href="../../../css/cmms.css" />
		<link rel="stylesheet" href="../../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../../css/doctor/order.css" />
		<link rel="stylesheet" href="../../../css/sale/payment/order.css"/>
		<script src="../../../js/vconsole.min.js"></script>
	</head>
	<body>
		<div class="mui-content" id="order" v-cloak>
			<div class="search">
				<div class="selectRange">
					<div @tap="selectState">
						{{selState}}<i class="icon iconfont icon-jiantou"></i>
					</div>
				</div>
				<input type="text" placeholder="请输入客户或医生或患者" v-model="doctorName"/>
				<span class="btn-primary" @tap='searchItem'>搜索</span>
			</div>
			<div class="wrap">
				<section class="panel order-panel" v-for="orders in orderList">
					<div @tap="orderDetail(orders.orderId)">
						<div class="overflow order-title">
							<span>{{orders.patientName}}</span>
							<span>{{orders.submitTime|replaceT}}</span>
							<span class="right"><i class="iconfont icon-shijian-"></i>{{orders.orderState+""|formatState}}</span>
						</div>
						<div class="check-server-code"><p>检验条形码：</p><p><span v-for="codeList in orders.specimenBarCode">{{codeList}}</span></p></div>
						<div class="check-item"><span v-for="name in orders.projectNmae">{{name}}</span></div>
						<div class="overflow check-item">
							<span>共<span class="basic-color">{{orders.projectNum}}</span>个检验项目<span class="basic-color"> ¥{{orders.amount}}</span></span>
							<span class="right"><i class="iconfont icon-icon1 basic-color"></i>{{orders.doctorName}}</span>
						</div>
					</div>
					<!--<div class="overflow get-report">-->
						<!--<span>预计{{orders.reportTime}}个工作日</span>-->
						<!--<span class="btn-detail right" @tap="orderDetail(orders.orderId)">订单详情</span>-->
					<!--</div>-->
				</section>
			</div>
		</div>
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/mui.picker.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../../js/vue.js"></script>
		<script src="../../../js/cmms.js?time=222"></script>
		<script>
			new Vue({
				el:"#order",
				data:{
					selState:'全部',
					selStateNum:'',
					doctorName:'',
					id:'',
					saleId:'',
					doctorId:'',
					startTime:'',
					endTime:'',
					webName:'',
					orderList:[],
					userId:''
				},
				mounted(){
//					var vConsole = new VConsole();
					this.getUrl();
					this.loadInfo();
					
				},
				methods:{
					getUrl(){
						let _this=this;
						var url = location.search; //获取url中"?"符后的字串    
						var theRequest = new Object();  
//						console.log(url);
					   	if (url.indexOf("?") != -1) {   
					      var str = url.substr(1);  
//					      console.log(str);
					      strs = str.split("&");  
					      for(var i = 0; i < strs.length; i ++) {   
					         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);   
					      } 
					   	}   
					   	console.log(theRequest);
					   	_this.startTime = theRequest.startTime;
					   	_this.endTime = theRequest.endTime;
					   	_this.id = theRequest.id;
					   	_this.saleId = theRequest.saleId;
					   	_this.doctorId = theRequest.doctorId;
					   	_this.webName = theRequest.webName;
					},
					loadInfo(){
						let _this = this;
						console.log(_this.id);
						//获取userID
						AT.muiAjax('/partner-sale/statistics/getHome','post',{},function(res){
							console.log(res);
							_this.userId = res.id;
						});
						if(_this.webName =='statistics'){
							AT.muiAjax('/partner-sale/order/getBySaleId','post',{
								id:_this.id,
								name:_this.doctorName,
								state:_this.selStateNum
							},
							function(res){
								console.log(res);
								_this.orderList = res;
							});
						}else if(_this.webName =='salePerform'){
							AT.muiAjax('/partner-sale/order/getOrderBySaleId','post',{
								starTime:_this.startTime,
								endTime:_this.endTime,
								saleId:_this.saleId,
								name:_this.doctorName,
								state:_this.selStateNum
							},
							function(res){
								console.log(res);
								_this.orderList = res;
							});
						}else if(_this.webName =='docPerform'){
							AT.muiAjax('/partner-sale/order/getOrderByDoctorId','post',{
								starTime:_this.startTime,
								endTime:_this.endTime,
								saleId:_this.doctorId,
								name:_this.doctorName,
								state:_this.selStateNum
							},
							function(res){
								console.log(res);
								_this.orderList = res;
							});
						}
					},
					/*搜索*/
					searchItem(){
						this.loadInfo();
					},
					/*状态选择*/
					selectState:function(){
						let _this = this;
						var picker = new mui.PopPicker();
						picker.setData([
							{value:'',text:'全部'},
							{value:'1',text:'未支付'},
							{value:'5',text:'支付中'},
							{value:'13',text:'已支付'},
							{value:'9',text:'送检中'},
							{value:'10',text:'检验中'},
							{value:'11',text:'生成报告'},
							{value:'12',text:'已取消'}
						]);
						picker.show(function (selectItems) {
						    _this.selState=selectItems[0].text;
						    _this.selStateNum=selectItems[0].value;
						    _this.loadInfo();
						})
					},
					orderDetail(orderId){
						console.log(orderId);
						location.href = "./../orderDetail.html?id="+orderId+"&userId="+this.userId;
					}
				}
			})
		</script>
	</body>
</html>

